
import { RouteRecordRaw } from "vue-router";
import { importComponent, returnFirstRouterPath } from "../utils"
// import accountManagementRouter from "./accountManagement"
import dataCollectRouter from "./dataCollect"
import tagManagementRouter from "./tagManagement"
import taskManagementRouter from "./taskManagement"
import AppLayout from "@/layouts/app-layout.vue"
// 2. 定义一些路由

// 顶层路由
const commonRouter: Array<RouteRecordRaw> = [
  {
    // 以 / 开头的嵌套路径将被视为根路径
    path: "/login",
    // 命名路由
    name: "Login",
    component: importComponent('login'),
  },
  {
    path: "/account-property",
    name: "AccountProperty",
    component: importComponent('account-property'),
  },
  {
    path: "/account-management",
    name: "AccountManagement",
    component: importComponent('account-management/account-list'),
  },
  {
    // 匹配任意路径，将匹配所有内容并将其放在 `$route.params.pathMatch` 下
    path: '/:pathMatch(.*)*',
    name: 'NotFound',
    component: importComponent('404')
  }
];

// 嵌套组件路由
const baseRouter: Array<RouteRecordRaw> = [
  dataCollectRouter,
  taskManagementRouter,
  // accountManagementRouter,
  tagManagementRouter
]

// 顶层默认路由
const rooterRouter: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "app",
    redirect: returnFirstRouterPath(baseRouter),
    component: AppLayout,
    children: baseRouter
  },
  ...commonRouter
]

export { rooterRouter, baseRouter };